﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
	<Style x:Key="ButtonFocusVisual">
		<Setter Property="Control.Template">
			<Setter.Value>
				<ControlTemplate>
					<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
	<Style x:Key="SlidingToggleButton" TargetType="{x:Type ToggleButton}">
		<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="HorizontalContentAlignment" Value="Center"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="Padding" Value="1"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ToggleButton}">
					<ControlTemplate.Resources>
						<Storyboard x:Key="ToggleOn">
							<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="SlidingBorder">
								<EasingThicknessKeyFrame KeyTime="0:0:0.1" Value="15,0,0,0"/>
								<EasingThicknessKeyFrame KeyTime="0:0:0.2" Value="40,0,0,0"/>
							</ThicknessAnimationUsingKeyFrames>
						</Storyboard>
						<Storyboard x:Key="ToggleOff">
							<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="SlidingBorder">
								<EasingThicknessKeyFrame KeyTime="0:0:0.1" Value="0"/>
							</ThicknessAnimationUsingKeyFrames>
						</Storyboard>
					</ControlTemplate.Resources>
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="80" />
						</Grid.ColumnDefinitions>
						
						<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="4" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
						<Grid Grid.Column="1" Width="Auto" Background="{x:Null}">
							<Border BorderBrush="#FF9DA2A4" BorderThickness="1" CornerRadius="1">
								<Border.Background>
									<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
										<GradientStop Color="White" Offset="1"/>
										<GradientStop Color="#FF858688"/>
										<GradientStop Color="#FFDBDCDD" Offset="0.112"/>
										<GradientStop Color="#FFAAABAD" Offset="0.04"/>
										<GradientStop Color="#FFCACBCC" Offset="0.08"/>
										<GradientStop Color="#FFFEFEFE" Offset="0.149"/>
									</LinearGradientBrush>
								</Border.Background>
							</Border>
							<TextBlock TextWrapping="Wrap" Text="OFF" d:LayoutOverrides="Width, Height" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"/>
							<TextBlock TextWrapping="Wrap" Text="ON" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0"/>
							<Border x:Name="SlidingBorder" BorderBrush="Black" BorderThickness="1" Width="40" HorizontalAlignment="Left" CornerRadius="1" Background="{TemplateBinding Background}">
								<Border BorderThickness="1">
									<Border.Background>
										<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
											<GradientStop Color="#00000000" Offset="0"/>
											<GradientStop Color="#7FFFFFFF" Offset="1"/>
										</LinearGradientBrush>
									</Border.Background>
								</Border>
							</Border>
						
						</Grid>
						<Border x:Name="DisabledBorder" BorderBrush="{x:Null}" BorderThickness="1" Grid.ColumnSpan="2" CornerRadius="1" Background="White" Opacity="0" IsHitTestVisible="False"/>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsKeyboardFocused" Value="true"/>
						<Trigger Property="IsChecked" Value="true">
							<Trigger.ExitActions>
								<BeginStoryboard x:Name="ToggleOff_BeginStoryboard" Storyboard="{StaticResource ToggleOff}"/>
							</Trigger.ExitActions>
							<Trigger.EnterActions>
								<BeginStoryboard Storyboard="{StaticResource ToggleOn}"/>
							</Trigger.EnterActions>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="#ADADAD"/>
							<Setter Property="Opacity" TargetName="DisabledBorder" Value="0.35"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="BorderBrush" Value="#FF2F63FF"/>
	</Style>
</ResourceDictionary>